# # 以下时间复杂度太高，需要更新
# def CheckPass(List, k):
#     Max_len = 1
#     if k == len(List) - 1:
#         return 1
#     for j in range(k + 1,len(List)):
#         if List[j] > List[k]:
#             Max_len = max(Max_len, CheckPass(List, j) + 1)
#     return Max_len

# def Check_max(List):
#     return max(CheckPass(List, i) for i in range(len(List)))

# while True:
#     try:
#         input()
#         print(Check_max(list(map(int,input().split()))))
#     except:
#         break

# 动态管理和记忆化搜索很重要
def CheckPass(List, k):
    if k in Dict:
        return Dict[k]
    Max_len = 1
    if k == len(List) - 1:
        return 1
    for j in range(k + 1,len(List)):
        if List[j] > List[k]:
            Max_len = max(Max_len, CheckPass(List, j) + 1)
    Dict[k] = Max_len
    return Max_len
def Check_max(List):
    return max(CheckPass(List, i) for i in range(len(List)))

while True:
    try:
        Dict = {}
        input()
        print(Check_max(list(map(int,input().split()))))
    except:
        break

# 还有迭代算法
# https://www.bilibili.com/video/BV1AB4y1w7eT